package com.example.demo.service.ServiceImp;

import com.example.demo.api.Dto.EmployeeDto;
import com.example.demo.domain.entity.Employee;
import com.example.demo.domain.repository.EmployeeRepository;
import com.example.demo.service.assembler.EmployeeAssembler;
import org.springframework.stereotype.Service;
import com.example.demo.service.EmployeeService;

import java.util.List;

@Service
public class EmployeeServiceImp implements EmployeeService {

    private final EmployeeRepository employeeRepository;

    public EmployeeServiceImp(EmployeeRepository employeeRepository) {

        this.employeeRepository = employeeRepository;
    }


    @Override
    public List<Employee> listEmployees(EmployeeDto employeeDto) {

        List<Employee> employeeList = employeeRepository.findEmployeeByCondition(EmployeeAssembler.toEmployee(employeeDto));
        return employeeList;
    }

    @Override
    public Employee findEmployeeById(Integer employeeId) {
        return employeeRepository.findEmployeeById(employeeId);
    }

    @Override
    public Employee getEmployeeWithLeader(EmployeeDto employeeDto) {
        return employeeRepository.getEmployeeWithLeader(employeeDto);
    }

    @Override
    public List<Employee> getEmployeeList(EmployeeDto employeeDto) {
        return employeeRepository.getEmployeeList(employeeDto);
    }

    @Override
    public void updateEmployee(EmployeeDto employeeDTO) {
        employeeRepository.updateEmployee(employeeDTO);
    }

    @Override
    public void insertEmployee(EmployeeDto employeeDTO) {
        employeeRepository.insertEmployee(employeeDTO);
    }

}
